import { type Ref } from 'vue';
import type { InjectionKey } from 'vue';
import { createContext, useContext } from '@vc/use';
import { type ReactiveVariable } from 'vue/macros';

/**
 * @description 菜单中的 context
 * @author wfd
 * @date 2021-07-21 14:52:44
 */
export interface TestContextProps {
  name: Ref<string>;
  age: number
  height: ReactiveVariable<number>;
}

const key: InjectionKey<TestContextProps> = Symbol();

export function createTestContext(context: TestContextProps) {
  return createContext<TestContextProps>(context, key, {
    native: true
  });
}

export function useTestContext() {
  return useContext<TestContextProps>(key);
}
